package com.mz.ozy.mvp.presenter;

import android.app.Activity;

import com.mz.ozy.base.BasePresenterImpl;
import com.mz.ozy.bean.NewMyExtendBean;
import com.mz.ozy.bean.NewMyExtendInfoBean;
import com.mz.ozy.mvp.model.ExtendModel;
import com.mz.ozy.mvp.view.ExtendContract;
import com.mz.ozy.net.MyObserver;
import com.mz.ozy.utils.RxUtil;

import okhttp3.ResponseBody;

public class ExtendPresenter extends BasePresenterImpl<ExtendContract.View> implements ExtendContract.Presenter {

    private ExtendModel mModel;

    public ExtendPresenter() {
        mModel = new ExtendModel();
    }


    @Override
    public void list(Activity activity, String page, String type) {
        mModel.list(activity, page, type)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<NewMyExtendBean>(mView) {
                    @Override
                    public void onSuccesss(NewMyExtendBean bean) {
                        mView.listSuccess(bean);
                    }
                });
    }

    @Override
    public void info(Activity activity, String id) {
        mModel.info(activity, id)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<NewMyExtendInfoBean>(mView) {
                    @Override
                    public void onSuccesss(NewMyExtendInfoBean bean) {
                        mView.infoSuccess(bean);
                    }
                });
    }
}
